import path from 'node:path';
import { config } from '../util';
import { Ui2Wx, Wx2Ui } from '.';

export abstract class Transformer {
  src: string;
  dest: string;

  initSuccess: Boolean = false

  srcType: string = 'wx';
  destType: string = 'ui';

  constructor(src: string, dest: string) {
    if (this instanceof Ui2Wx) {
      this.srcType = 'ui';
      this.destType = 'wx';
    } else if (this instanceof Wx2Ui) {
      this.srcType = 'wx';
      this.destType = 'ui';
    }

    this.src = src || config.cwd;
    this.dest = dest || path.join(config.cwd, `${path.basename(config.cwd)}-${this.destType}`);
    this.initSuccess = this.init();
  }

  abstract init(): boolean
  abstract transform(): void
}
